const token = localStorage.token;
let userInfo;
if (token) {
  $.ajaxSetup({
    headers: {
      Authorization: token
    },
    async: false,
    error(err) {
      if (err.status !== 401) return alert("123");
      alert("登录已过期，请重新登录");
      location.href = "../login.html";
    }
  });
} else {
  alert("你还未登录，请先登录");
  location.href = "./login.html";
}
getUser();
//获取用户信息
function getUser() {
  $.ajax({
    url: "/students/getUserInfo",
    type: "POST",
    success(data) {
      userInfo = data.data[0];
      console.log("用户信息", userInfo);
    }
  });
}
